package PTA_JAVA.Collection7.demo2;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.nextLine();;
        Map<String,Integer> map = new HashMap<String,Integer>();
        while (!s.equals("!!!!!")) {
            if (s.equals(" ")) {
                s = sc.next();
                continue;
            } else {                                //!.,:*?
                String[] str = s.replaceAll("\\!|\\.|\\,|\\:|\\*|\\?", " ").split("\\s+");
                for(String s1:str){
                    String i=s1.toLowerCase();
                    if(map.containsKey(i)){
                        Integer value= map.get(i);
                        value++;
                        map.put(i,value);
                    }else{
                        map.put(i,1);
                    }
                }
                s = sc.next();
            }
        }
        List<Map.Entry<String,Integer>> arr=new ArrayList<Map.Entry<String,Integer>>(map.entrySet());
        Collections.sort(arr, new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                if(o1.getValue().equals(o2.getValue())){
                    return o1.getKey().compareTo(o2.getKey());
                }else{
                    return o2.getValue().compareTo(o1.getValue());
                }
            }
        });

        System.out.println(arr.size());
        int num = 0;
        for (Map.Entry<String, Integer> i : arr) {
            System.out.println(i.getKey() + "=" + i.getValue());
            if(++num == 10) {
                break;
            }
        }
    }
}
